<template>
	<view>
	<view class="list" v-if="dataList.length!=0">
			<view class="li" v-for="(item, index) in dataList" :key="index" @click="details(item.id)">
				<view class="shop">
					<image :src="item.image" class="imgthumb" :lazy-load = "true" mode="aspectFill"/>
					<view class="msg">
						<view class="order black">{{item.productName}}</view>
						<view class="sizr gray " v-for="(sku, index1) in item.sku" :key="index1">{{sku}}</view>
						<view class="order black">合计：￥{{item.orderPrice}}</view>
						
					</view>
				</view>
				<view class="genre">
					<text>{{item.auditResult.desp}}</text>
					<view class="msg">
						<view class="audit">查看详情</view>
					</view>
				</view>
				<view  class="orderfrom" >
						<text class="orderfrom">操作时间：{{item.operationTime}}</text>
				</view>
			</view>
		</view>
		<view class="pagination" v-if="dataList.length!=0">
			<view class="left" :class="{ forbid: paging.page == 1 }" @click="prev">
				<uni-icons type="arrowleft" size="20" color="#fff" class="icons" />
				上一页
			</view>
			<view class="center">{{ paging.page }}/{{ paging.total }}</view>
			<view class="right" :class="{ forbid: paging.page == paging.total }" @click="next">
				下一页
				<uni-icons type="arrowright" size="20" color="#fff" class="icons" />
			</view>
		</view>
		<view class="pagination" v-if="dataList.length!=0">
			<view class="left" :class="{ forbid: paging.page == 1 }" @click="prev">
				<uni-icons type="arrowleft" size="20" color="#fff" class="icons" />
				上一页
			</view>
			<view class="center">{{ paging.page }}/{{ paging.total }}</view>
			<view class="right" :class="{ forbid: paging.page == paging.total }" @click="next">
				下一页
				<uni-icons type="arrowright" size="20" color="#fff" class="icons" />
			</view>
		</view>
	</view>
</template>

<script>
import { uniNavBar, uniIcons, uniPopup } from '@dcloudio/uni-ui';
import order from '../../servers/servers/order.js';
export default {
components: { uniNavBar, uniIcons, uniPopup },
	data() {
		return {
			obj:'',/* 查询参数 */
			dataList:[],
			paging: {
				page: 1,
				total: 100
			}
			
		};
	},
	mounted() {
		var _this = this
		uni.getStorage({
		    key: 'agentadvertisinglist',
		    success: function (res) {
		        _this.obj = res.data;
				_this.getData();
		    }
		});
		
	},
	methods: {
		getData(){
			uni.showLoading({
			    title: '数据加载中'
			});	
			this.dataList=[];/* 置为空 */
			this.obj.currentPage= this.paging.page;
			this.obj.pageSize=10;	
			entrepot.initData(obj)
				.then(res => {
				this.paging.total = Math.ceil(res.data.total / res.data.size);
				this.paging.page=res.data.current
				this.dataList=res.data.records.map(v => {
					v.image = this.imgCDNUrl + v.productImg;
					var sku=[];
					if(v.productSkuDesp){
						sku=v.productSkuDesp.split(",");
					}
					v.sku=sku;
					return v;
				});
				uni.hideLoading();
			
				})
				.catch(err => {
					console.log(new Error('请检查网络后重试'));
				});
		},
		audit(e){
			/* var itemList= ['通过', '拒绝']
			uni.showActionSheet({
			    itemList: itemList,
			    success: function (res) {
			        console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
			        console.log(res);
					uni.showModal({
					    content: '您确定要'+itemList[res.tapIndex]+'审核吗？',
						confirmColor: '#bd3c8c',
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					
			    },
			    fail: function (res) {
			        console.log(res.errMsg);
			    }
			}); */
			uni.setStorage({
			    key: 'entrepotdetails',
			    data: e,
			    success: function () {
			        uni.navigateTo({
			            url: './details'
			        });
			    }
			});
		},
		next() {
			if (this.paging.page < this.paging.total) {
				this.paging.page += 1;
				this.getData();
			}
			
		},
		prev() {
			if (this.paging.page > 1) {
				this.paging.page -= 1;
				this.getData();
			}
			
		}
	}
};
</script>

<style lang="less" scoped>
.list {
	padding: 0 20rpx;
	background: #ffffff;
	.li {
		padding: 50rpx 0;
		border-bottom: 1px solid #e1e1e1;
		.shop {
			position: relative;
			display: flex;
			flex-direction: row;
			image {
				width: 230rpx;
				height: 230rpx;
				border-radius: 10rpx;
			}
			.msg {
				position: relative;
				width: 431rpx;
				margin-left: 37rpx;
				line-height: 46rpx;
				.order {
					font-size: 28rpx;
				}
				.type {
					font-size: 26rpx;
				}
				.gray {
					color: #999999;
					font-size: 26rpx;
					line-height: 42rpx;
				}
			}
			.number {
				position: absolute;
				bottom: 0;
				color: #999999;
				font-size: 26rpx;
				.price {
					display: inline-block;
					color: #333333;
					margin-left: 29rpx;
					text {
						font-size: 30rpx;
						color: #333333;
					}
				}
			}
		}
		.genre {
			position: relative;
			color: #bd3c8c;
			display: flex;
			flex-direction: row;
			padding-top: 57rpx;
			font-size: 24rpx;
			.type {
				width: 322rpx;
			}
			.audit {
				position: absolute;
				bottom: -15rpx;
				right: 0;
				width: 150rpx;
				height: 60rpx;
				line-height: 60rpx;
				border-radius: 60rpx;
				border: 1px solid #f70225;
				color: #f70225;
				text-align: center;
			}
		}
	}
	.li:nth-last-child(1) {
		border-bottom: none;
	}
	
}
</style>
